#!/usr/bin/env python
# Parse Apache access logs 
import re
import os
import sys
import time
import cPickle as pickle

DB = os.path.join(os.environ['HOME'],'apachedb.pickle')

def main():
    if sys.argv[1:]:
        key = sys.argv[1]
    else:
        key = ''

    f = file(DB)
    db = pickle.load(f)
    f.close()

    for k,v in db.iteritems():
        if key in k:
            print k,len(v)

if __name__=='__main__':
    main()
